class Admin::BaseController < ApplicationController
	layout 'admin'
	before_filter :authenticate
	
	ADMIN_PER_PAGE = 20
	
	#判断是否登录
  def authenticate
    unless current_admin
      flash[:notice] = "你还没有登录系统，请登录..."
      redirect_to '/admin_login'
    end
  end
  
  protected
  def current_admin
    if session[:admin_user]
      @current_admin ||= AdminUser.find_by_id(session[:admin_user])
    end
  end
  
  def store_location
    session[:return_to] = request.referrer
  end
  
  def return_to
    redirect_to session[:return_to]
  end
  
end
